package com.fymxy.question_bank_management.controller;

import com.fymxy.question_bank_management.pojo.ApiResult;
import com.fymxy.question_bank_management.pojo.Student;
import com.fymxy.question_bank_management.service.StudentService;
import com.fymxy.question_bank_management.util.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StudentRegisterController {

    @Autowired
    private StudentService studentService;

    @PostMapping("/student/register")
    public ApiResult addStudent(@RequestBody Student student){
        int addStudentRes = studentService.insert(student);//1成功，0失败
        if(addStudentRes == 1)
            return ApiResultHandler.buildApiResult(200, "注册成功", addStudentRes);
        else
            return ApiResultHandler.buildApiResult(400, "注册失败", addStudentRes);
    }


}
